In the following exercises we will collect and explore some data from YouTube.
yt_oauth from the tuber package which requires the ID of your app as well as your app secret as arguments.
While going through the following exercises you might want to monitor your API quota usage via the Google Cloud Platform dashboard for your app (APIs & Services -> Dashboard -> Select YouTube Data API v3 -> Quotas) to see the query costs for the tuber function calls.
get_channel_stats function which requires the ID the channel (as a string) as its main argument.
get_channel_stats("UCwbQkZf9gjqDvbK4_H6qAOw")
get_stats and need the ID of the video.
get_stats("uHGlCi9jOWY")
comments_lwt_census.
get_all_comments.
comments_lwt_census <- get_all_comments("1aheRpmurAo")
NB: If you check the comment count on the website of the video you will see that there are more comments than in the dataframe you just created. This is because get_all_comments only collects up to 5 replies per comment.
base R function saveRDS. Ideally, you should save the file in the folder containing the workshops materials. The code in the solution uses a relative path to save the file in your current working directory.
saveRDS(comments_lwt_census, "./Comments.rds")